package com.zjj.crypt.advice;


import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpInputMessage;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;

/**
 * 请求数据解密
 *
 * @author zjjj_admin
 **/
public class DecryptHttpInputMessage implements HttpInputMessage {


    private HttpInputMessage inputMessage;
    private String deData;


    public DecryptHttpInputMessage(HttpInputMessage inputMessage, String deData) {
        this.inputMessage = inputMessage;
        this.deData = deData;
    }


    @Override
    public InputStream getBody() {

        ByteArrayInputStream inputStream = new ByteArrayInputStream(this.deData.getBytes(StandardCharsets.UTF_8));
        return inputStream;
    }


    @Override
    public HttpHeaders getHeaders() {
        return this.inputMessage.getHeaders();
    }
}